#ifndef TEXTCONTEXTBUILDER_H
#define TEXTCONTEXTBUILDER_H

#include "textcontext.h"
#include "freetextcontext.h"
#include "organizedtextcontext.h"

/****************************************************
  Builder of TextContext.
 ****************************************************/
class TextContextBuilder
{
public:
    static const int STYLE_FREE = 0;
    static const int STYLE_ORGANIZED = 1;

    TextContextBuilder();
    virtual ~TextContextBuilder();

    // Create a TextContext by given style
    TextContext * create(int style){
        switch(style){
        case STYLE_FREE:
            _context = new FreeTextContext();
            break;
        case STYLE_ORGANIZED:
            _context = new OrganizedTextContext();
            break;
        default:
            return 0;
        }
        return _context;
    }

    // Set the format of an OrganizedTextContext
    TextContext * setFormat(int charsPerLine, int linesPerPage){
        ((OrganizedTextContext *)_context)->setFormat(charsPerLine, linesPerPage);
        return _context;
    }

private:
    TextContext * _context;
};

#endif // TEXTCONTEXTBUILDER_H
